version: '3.4'

services:
  su-zookeeper:
    image: confluentinc/cp-zookeeper:7.2.0
    container_name: su-zookeeper
    restart: always
    environment:
      ZOOKEEPER_CLIENT_PORT: 2183
      ZOOKEEPER_TICK_TIME: 2000

  su-broker:
    image: confluentinc/cp-kafka:7.2.0
    container_name: su-broker
    restart: always
    ports:
    # To learn about configuring Kafka for access across networks see
    # https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
      - "9192:9192"
    depends_on:
      - su-zookeeper
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: 'su-zookeeper:2183'
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://su-broker:9192,PLAINTEXT_INTERNAL://su-broker:29192
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1

  app_with_updater:
    image: app_with_updater
    build:
      context: .
      dockerfile: ./Dockerfile.app_with_updater
    depends_on:
      - su-broker
    ports:
      - "5000:5000"

  file_server:
    image: file_server
    build:
      context: .
      dockerfile: ./Dockerfile.file_server    
    volumes:
      - ./file_server/data/:/file_server/data
    ports:
      - "5001:5001"

  monitor:
    image: monitor
    build:
      context: .
      dockerfile: ./Dockerfile.monitor
    depends_on:
      - su-broker

  downloader:
    image: downloader
    build:
      context: .
      dockerfile: ./Dockerfile.downloader    
    depends_on:
      - file_server
      - su-broker

  storage:
    image: storage
    build:
      context: .
      dockerfile: ./Dockerfile.storage
    depends_on:
      - su-broker

  verifier:
    image: verifier
    build:
      context: .
      dockerfile: ./Dockerfile.verifier
    depends_on:
      - su-broker
      - storage

  manager:
    image: manager
    build:
      context: .
      dockerfile: ./Dockerfile.manager
    depends_on:
      - su-broker      
      - monitor
      - downloader
      - verifier
      - storage
      - app_with_updater
    ports:
      - "5002:5002"
